﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ShopOnline.Models.DAL
{
    public class DAL_Device
    {
         private ShopOnline.Models.ShopOnlineDBDataContext SC_DB;
         public DAL_Device()
        {
            SC_DB = new ShopOnlineDBDataContext();
        }

         public List<Device> getListDevice()
        {
            return SC_DB.Devices.ToList();
        }

         public List<Device> getListDeviceIsShow()
        {
            return (from c in SC_DB.Devices where c.Show == true select c).ToList();
        }

         public Device getDeviceById(int DeviceId)
        {
            return (from c in SC_DB.Devices where c.Id == DeviceId select c).FirstOrDefault();
        }

         public List<Device> getNDevicePaging(int n, int skip)
         {
             return (from d in SC_DB.Devices orderby d.Id where d.Show == true select d).Skip(n).Take(skip).ToList();
         }

    }
}